//
//  GXTableViewHeadView.m
//  10-TableViewCellHomework
//
//  Created by 曹曹 on 16/7/27.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "GXTableViewHeadView.h"
#import "GXCycleImages.h"
#import "UIView+Frame.h"
#import "GXIconLabelView.h"

@implementation GXTableViewHeadView

- (instancetype)initWithFrame:(CGRect)frame images:(NSArray *)images {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        CGFloat leftMargin = 15;
        CGFloat middleMargin = 25;
        CGFloat gxViewWidth = (self.gx_width - middleMargin * 3 - leftMargin * 2) / 4;
        GXCycleImages *cycle = [[GXCycleImages alloc] initWithFrame:CGRectMake(0, 0, self.gx_width, self.gx_height * 3 / 4)];
        cycle.cycleScrollView.showsHorizontalScrollIndicator = NO;
        [cycle setImagesWithArray:images];
        cycle.imagesPageControl.currentPageIndicatorTintColor = [UIColor redColor];
        cycle.imagesPageControl.pageIndicatorTintColor = [UIColor grayColor];
        [self addSubview:cycle];
#pragma mark -
        CGFloat gxViewHeight = self.gx_height / 4;
        GXIconLabelView *gxView1 = [[GXIconLabelView alloc] initWithFrame:CGRectMake(leftMargin, cycle.gx_height, gxViewWidth, gxViewHeight) image:@"1" bottomText:@"贷款买车"];
        [self addSubview:gxView1];
        CGFloat view2X = leftMargin + gxViewWidth + middleMargin;
        GXIconLabelView *gxView2 = [[GXIconLabelView alloc] initWithFrame:CGRectMake(view2X, cycle.gx_height, gxViewWidth, gxViewHeight) image:@"2" bottomText:@"直销车型"];
        [self addSubview:gxView2];
        CGFloat view3X = view2X + gxViewWidth + middleMargin;
        GXIconLabelView *gxView3 = [[GXIconLabelView alloc] initWithFrame:CGRectMake(view3X, cycle.gx_height, gxViewWidth, gxViewHeight) image:@"3" bottomText:@"底价买车"];
        [self addSubview:gxView3];
        CGFloat view4X = view3X + gxViewWidth + middleMargin;
        GXIconLabelView *gxView4 = [[GXIconLabelView alloc] initWithFrame:CGRectMake(view4X, cycle.gx_height, gxViewWidth, gxViewHeight) image:@"4" bottomText:@"二手车"];
        [self addSubview:gxView4];
    }
    return self;
}

@end
